package com.starbaba.core.web.struts2;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.starbaba.core.exception.TaskException;
import com.starbaba.system.common.AsynchronousTaskFactory;
//import com.mtech.session.SessionManager;

/**
 * 初始化Web配置
 *
 * @Copyright: Copyright (c) 2006
 * @Company: Revenco Tech Ltd.
 * @anthor chenminhui<chenminhui@revenco.com>
 * @since 2014-11-4 下午07:55:23
 * @version V1.0
 */
public class InitWebConfigListener implements ServletContextListener {
	
	private Logger log = LoggerFactory.getLogger(getClass());
	
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		log.info("关闭session插件...");
//		SessionManager.shutdown();
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		try {
			AsynchronousTaskFactory.getFactory().addTask(new Runnable(){

				@Override
				public void run() {
					log.info("初始化session插件...");
//					SessionManager.init(null);
					log.info("初始化session插件成功");
				}});
		} catch (TaskException e) {
			e.printStackTrace();
		}
	}

}
